package com.bootdo.wechat.common;

import com.bootdo.wechat.domain.MpFansDO;
import com.bootdo.wechat.utils.UUIDUtil;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;

/**
 * @author songj
 * @version ${VERSION}
 * @Title: bootdo-wechat
 * @Package com.bootdo.wechat.common
 * @Description: ${TOTO} (用一句话描述该文件做什么)
 * @date 2018/8/3  14:45
 */
public class CopyUtils {
    private static Logger logger = LoggerFactory.getLogger(CopyUtils.class);
    public static MpFansDO copyFans(WxMpUser userWxInfo){
        MpFansDO fansDO = new MpFansDO();
        try {
            BeanUtils.copyProperties(userWxInfo,fansDO);
        }catch (Exception e){
            logger.error("copy错误：{}",e);
        }
        fansDO.setId(UUIDUtil.get12UUID());
        fansDO.setSubscribe(0);
        fansDO.setOpenId(userWxInfo.getOpenId());
        fansDO.setHeadimgurl(userWxInfo.getHeadImgUrl());
        fansDO.setSubscribeTime(userWxInfo.getSubscribeTime());
        fansDO.setUnionid(userWxInfo.getUnionId());
        return fansDO;
    }
}
